package cn.wolfcode.wolf2w.business.controller;

import cn.wolfcode.wolf2w.common.core.domain.R;
import cn.wolfcode.wolf2w.common.security.annotation.InnerAuth;
import cn.wolfcode.wolf2w.business.api.domain.Reply;
import cn.wolfcode.wolf2w.business.query.ReplyQuery;
import cn.wolfcode.wolf2w.business.service.IReplyService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 回答 Controller
 * 
 * @author SQM
 * @date 2024-11-18
 */
@RestController
@RequestMapping("replys")
public class ReplyController {
    @Autowired
    private IReplyService replyService;
    /**
     * 回答详情
     */
    @GetMapping("/detail/{id}")
    public R<Reply> detail(@PathVariable Long id) {
        Reply reply = replyService.getById(id);
        return R.ok(reply);
    }
    /**
     * 回答 列表
     */
    @GetMapping("/query")
    public R<IPage<Reply>> query(ReplyQuery qo) {
        IPage<Reply> page = replyService.queryPage(qo);
        return R.ok(page);
    }


    /*****************************************对外暴露Fegin接口**********************************************/
    /**
     * Feign 接口
     */
    @GetMapping("/feign/list")
    public R<List<Reply>> feignList() {
        return R.ok(replyService.list());
    }
    @InnerAuth
    @GetMapping("/feign/{id}")
    public R<Reply> feignGet(@PathVariable Long id) {
        return R.ok(replyService.getById(id));
    }
}
